<?php


namespace app\job;

use app\admin\model\UserRelation;
use think\facade\Log;
use think\queue\Job;
use app\service\IyunBinkService;
class IyunLoginJob
{
    /**
     * 报表
     */
    public function fire(Job $job, $data){
        $isJobDone = $this->doTask($data);
        if ($isJobDone) {
            $job->delete();
        }else{
            $job->release(2);
        }

    }

    /**
     *
     * task具体执行逻辑
     */
    public function doTask($data){
        $params=IyunBinkService::regist($data['mobile'],$data['name'],$data['password']);
        //$res = Db::table('chd_auth_role')->insert($params);
        Log::info("==任务执行ok==".json_encode($params));
        if ($params['status']=='1'){
            $userModel=new UserRelation();
            $userModel->setCreate($data['user_id'],$params['data']['uniqueId'],2);
            return true;
        }else{
            return false;
        }

    }
}